﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Coding4Fun.Toolkit.Controls;assembly=Coding4Fun.Toolkit.Controls"
    x:Class="SampleApp.MotorControl"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    Width="170"
	Height="{Binding Width, RelativeSource={RelativeSource Self}}"
	Margin="0, 0, 10, 10"
	x:Name="ControlBody">
	<UserControl.Resources>
		<Style x:Key="LineStyle" TargetType="Line">
			<Setter Property="X2" Value="30"/>
			<Setter Property="StrokeStartLineCap" Value="Flat"/>
			<Setter Property="StrokeEndLineCap" Value="Flat"/>
			<Setter Property="StrokeThickness" Value="4"/>
			<Setter Property="Margin" Value="0, 0, 0, 5"/>
			<Setter Property="Stretch" Value="Uniform"/>
			<Setter Property="Fill" Value="{StaticResource PhoneContrastForegroundBrush}" />
			<Setter Property="Stroke" Value="{StaticResource PhoneContrastForegroundBrush}" />
		</Style>
		<Style x:Key="HamburgerStyle" TargetType="Button">
			<Setter Property="Padding" Value="0"/>
			<Setter Property="Margin" Value="0"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Grid Background="Transparent">
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Pressed">
										<!--<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneButtonBasePressedForegroundBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>-->
									</VisualState>
									<VisualState x:Name="Disabled">
										<!--<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
												<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>-->
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<StackPanel
								Margin="-10, 8, 0, 0"
								VerticalAlignment="Top">
								<Line Style="{StaticResource LineStyle}" />
								<Line Style="{StaticResource LineStyle}" />
								<Line Style="{StaticResource LineStyle}" />
							</StackPanel>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>
	
	<Grid>
		<Grid
			Background="White">
			<StackPanel 
				Margin="0, 2, 10, 10"
				HorizontalAlignment="Right"
				VerticalAlignment="Top">
				<TextBlock 
					Margin="0, 0, 0, -5"
					Foreground="#999"
					HorizontalAlignment="Right"
					FontSize="{StaticResource PhoneFontSizeSmall}">
					<Run Text="Unknown" x:Name="MotorType"/>
				</TextBlock>
				<TextBlock
					Foreground="#999"
					HorizontalAlignment="Right"
					FontSize="{StaticResource PhoneFontSizeSmall}">
					<Run Text="Port "/>
					<Run Text="???" x:Name="PortName"/>
				</TextBlock>
			</StackPanel>

			<StackPanel 
				Margin="8, 0, 0, 3"
				VerticalAlignment="Bottom">
				<TextBlock 
					Margin="0, 0, 0, -10"
					FontSize="{StaticResource PhoneFontSizeMedium}"
					Foreground="Black">
					<Run 
						Text="50" 
						x:Name="PowerPercentageRun" /><Run 
						Foreground="#999"
						Text="%"
						FontSize="14" /><Run 
						FontSize="8"
						Text=" " /><Run 
						Foreground="#999"
						Text="power"
						FontSize="{StaticResource PhoneFontSizeSmall}" />
				</TextBlock>
			

				<TextBlock 
					Name="TimeBasedTextBlock"
					FontSize="{StaticResource PhoneFontSizeMedium}"
					Foreground="Black">
					<Run 
						Text="5" 
						x:Name="SecondsRun"/><Run 
						FontSize="8"
						Text=" " /><Run 
						x:Name="SecondsDescRun"
						Foreground="#999"
						Text="seconds"
						FontSize="{StaticResource PhoneFontSizeSmall}" />
				</TextBlock>
				<TextBlock 
					Name="DegreesTextBlock"
					FontSize="{StaticResource PhoneFontSizeMedium}"
					Foreground="Black">
				<Run
					Text="5"
					x:Name="DegreesRun" /><Run 
					FontSize="8"
					Text=" " /><Run 
					Foreground="#999"
					Text="degrees"
					FontSize="{StaticResource PhoneFontSizeSmall}" />
				</TextBlock>
			</StackPanel>
			
			<Button
				Click="MotorSettingClick"
				Width="60"
				Height="{Binding Width, RelativeSource={RelativeSource Self}}"
				HorizontalAlignment="Left"
				VerticalAlignment="Top" 
				VerticalContentAlignment="Center"
				Style="{StaticResource HamburgerStyle}" />

			<controls:RoundButton
				Click="PlayClick"
				BorderBrush="{StaticResource PhoneContrastForegroundBrush}"
				Foreground="{StaticResource PhoneContrastForegroundBrush}"
				ButtonHeight="60"
				ButtonWidth="60"
				Padding="0"
				Margin="0, 0, 0, 0"
				HorizontalAlignment="Right"
				VerticalAlignment="Bottom">
				<Path 
					Margin="5, 0, 0, 0"
					Height="20" 
					Data="M26.9648,21.0951 L75.2695,48.6928 L26.9648,76.2904 z" 
					Stretch="Uniform" />
			</controls:RoundButton>
		</Grid>
		
		<Grid Visibility="Collapsed">
			<Grid.RowDefinitions>
				<RowDefinition Height="10" />
				<RowDefinition />
				<RowDefinition Height="10" />
			</Grid.RowDefinitions>
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="10" />
				<ColumnDefinition />
				<ColumnDefinition Width="10" />
			</Grid.ColumnDefinitions>

			<Rectangle Fill="Red" Opacity=".4" Grid.Row="0" Grid.ColumnSpan="3" />
			<Rectangle Fill="Red" Opacity=".4" Grid.Row="2" Grid.ColumnSpan="3" />

			<Rectangle Fill="Red" Opacity=".4" Grid.Column="0" Grid.RowSpan="3" />
			<Rectangle Fill="Red" Opacity=".4" Grid.Column="2" Grid.RowSpan="3" />


		</Grid>
	</Grid>
</UserControl>